//package com.arcvideo.acsconnect.ui.activity;
//
//import android.app.Activity;
//import android.content.Intent;
//import android.view.View;
//import android.widget.Button;
//import android.widget.ImageView;
//import android.widget.LinearLayout;
//import android.widget.RadioButton;
//import android.widget.RadioGroup;
//import android.widget.TextView;
//
//import com.arcvideo.acsconnect.app.CodeRateEnum;
//import com.arcvideo.acsconnect.app.ResolutionEnum;
//import com.arcvideo.acsconnect.app.SettingDataCenter;
//import com.arcvideo.acsconnect.app.UserDataCenter;
//import com.arcvideo.acsconnect.ui.presenter.SettingPresenter;
//import com.arcvideo.acsconnect.ui.view.SettingView;
//import com.arcvideo.acsconnect.utils.ConfigUtil;
//import com.arcvideo.acsconnect.widget.MySeekBarLayout;
//import com.arcvideo.commondef.CameraTypes;
//import com.arcvideo.rtcmessage.utils.LogUtil;
//import com.arcvideo.tyingyitonginhouse.R;
//import com.framework.core.mvp.TitlePresenterActivity;
//import com.framework.core.utils.AppUtil;
//import com.framework.core.utils.ToastUtil;
//
//import java.io.File;
//import java.io.IOException;
//
//import butterknife.BindView;
//import butterknife.OnClick;
//
///**
// * @author shenmengchao
// * @version 1.0.0
// * @date 2017/7/27
// * @description
// */
//
//public class SettingActivity extends TitlePresenterActivity<SettingPresenter> implements SettingView {
//
//    public final static int REQUEST_CODE = 12;
//
//    //    @BindView(R.id.ll_output)
////    LinearLayout mLlOutput;
//    @BindView(R.id.ll_setting_output)
//    LinearLayout mLlSettingOutput;
//    @BindView(R.id.sb_frame)
//    MySeekBarLayout mSbFrame;
//    @BindView(R.id.iv_arrow_setting)
//    ImageView mIvArrowSetting;
//    //    @BindView(R.id.rb_2)
////    RadioButton mRb2;
////    @BindView(R.id.rb_3)
////    RadioButton mRb3;
////    @BindView(R.id.rb_4)
////    RadioButton mRb4;
////    @BindView(R.id.radio_group)
////    RadioGroup mRadioGroup;
////    @BindView(R.id.ll_account)
////    LinearLayout mLlAccount;
//    @BindView(R.id.ll_version)
//    LinearLayout mLlVersion;
//
//    SettingPresenter mSettingPresenter = new SettingPresenter();
//    @BindView(R.id.tv_version)
//    TextView mTvVersion;
////    @BindView(R.id.rb_h264)
////    RadioButton mRbH264;
////    @BindView(R.id.radio_group_video_decode_type)
////    RadioGroup mRadioGroupVideoDecodeType;
//
//    @BindView(R.id.sb_code)
//    MySeekBarLayout mSbCode;
//    @BindView(R.id.rb_aac)
//    RadioButton mRbAac;
//    @BindView(R.id.radio_group_audio_decode_type)
//    RadioGroup mRadioGroupAudioDecodeType;
//    @BindView(R.id.sb_audio_rate)
//    MySeekBarLayout mSbAudioRate;
//    @BindView(R.id.tv_quit)
//    TextView mTvQuit;
//    @BindView(R.id.tv_resolution)
//    TextView mTvResolution;
//
//    @BindView(R.id.btn_make_log_file)
//    Button mBtnMakeLogFile;
//
//    @BindView(R.id.tv_audio_record_type)
//    TextView mTvAudioType;
//
//    /////// for test //////////////////
//    @BindView(R.id.radio_group)
//    RadioGroup mRadioGroup;
//    @BindView(R.id.rb_phonecamera)
//    RadioButton mRbPhoneCamera;
//    @BindView(R.id.rb_usbcamera)
//    RadioButton mRbUsbCamera;
//
//    private boolean mIsOutputSettingShow = false;
//    private boolean mIsAccountSettingShow = false;
//
//    private int mLastCodeRate;
//
//    public static void launch(Activity activity) {
//        Intent intent = new Intent(activity, SettingActivity.class);
//        activity.startActivityForResult(intent, REQUEST_CODE);
//    }
//
//    @Override
//    public void initActivity(View view) {
//        super.initActivity(view);
//        showContent();
//        setHeaderTitle("设置");
//        mSbCode.setListener(new MySeekBarLayout.OnProgressListener() {
//            @Override
//            public void onProgressChanged(int value) {
//                SettingDataCenter.getInstance().setCodeRate(value);
//            }
//        });
//        mSbAudioRate.setListener(new MySeekBarLayout.OnProgressListener() {
//            @Override
//            public void onProgressChanged(int value) {
//                SettingDataCenter.getInstance().setAudioRate(value);
//            }
//        });
//        mSbFrame.setListener(new MySeekBarLayout.OnProgressListener() {
//            @Override
//            public void onProgressChanged(int value) {
//                SettingDataCenter.getInstance().setFps(value);
//            }
//        });
//        mLlSettingOutput.setVisibility(View.VISIBLE);
//
////        initAudioCodeRate();
//        initCodeRate();
//        initFrame();
//        initAudioRate();
//        initVersion();
//        initSourceType();
//        initAudioType();
//        if (ConfigUtil.isRelease()) {
//            mBtnMakeLogFile.setVisibility(View.GONE);
//        } else {
//            mBtnMakeLogFile.setVisibility(View.VISIBLE);
//        }
//    }
//
//    @Override
//    public SettingPresenter getPresenter() {
//        return mSettingPresenter;
//    }
//
//    @Override
//    public int inflateContentView() {
//        return R.layout.activity_setting;
//    }
//
//    @OnClick({R.id.ll_version, R.id.tv_quit, R.id.btn_make_log_file,
//            R.id.ll_resolution, R.id.ll_audio_record_type})
//    public void onClick(View view) {
//        switch (view.getId()) {
////            case R.id.ll_output:
////                mIsOutputSettingShow = !mIsOutputSettingShow;
////                if (mIsOutputSettingShow) {
////                    mLlSettingOutput.setVisibility(View.VISIBLE);
////                } else {
////                    mLlSettingOutput.setVisibility(View.GONE);
////                }
////                break;
////            case R.id.ll_account:
////                mIsAccountSettingShow = !mIsAccountSettingShow;
//////                if (mIsAccountSettingShow) {
//////                    mLlSettingAccount.setVisibility(View.VISIBLE);
//////                } else {
//////                    mLlSettingAccount.setVisibility(View.GONE);
//////                }
////                break;
//            case R.id.ll_version:
////                mSettingPresenter.upgrade(this);
//                break;
//            case R.id.tv_quit:
//                UserDataCenter.getInstance().cleanUserInfoBean();
////                LoginActivity.launch(this);
//                break;
//            case R.id.btn_make_log_file:
//                makeLogFile();
//                break;
//            case R.id.ll_resolution:
//                ResolutionActivity.launch(this);
//                break;
//            case R.id.ll_audio_record_type:
//                AudioRecordTypeActivity.launch(this);
//                break;
//        }
//    }
//
//    @Override
//    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//        super.onActivityResult(requestCode, resultCode, data);
//        switch (requestCode) {
//            case ResolutionActivity.REQUEST_CODE:
//                if (resultCode == RESULT_OK && null != data) {
//                    CodeRateEnum mCodeRateEnum = (CodeRateEnum) data.
//                            getSerializableExtra(ResolutionActivity.CODE_RATE);
//                    ResolutionEnum mResolutionEnum = (ResolutionEnum) data.
//                            getSerializableExtra(ResolutionActivity.RESOLUTION);
//                    setResolution(mResolutionEnum);
//                    setCodeRate(mCodeRateEnum);
//                    initResolutionText(mResolutionEnum);
//                }
//                break;
//            case AudioRecordTypeActivity.REQUEST_CODE:
//                initAudioType();
//                break;
//            default:
//                break;
//        }
//    }
//
//    private void makeLogFile() {
//        String rtcEngineLogFilePath = "sdcard/ArcRtcEngine_android_native.log";
//        File rtcEngineLogFile = new File(rtcEngineLogFilePath);
//        boolean isClear = false;
//        if (rtcEngineLogFile.exists()) {
//            isClear = true;
//            rtcEngineLogFile.delete();
//        }
//        boolean isSuccess = false;
//        try {
//            isSuccess = rtcEngineLogFile.createNewFile();
//        } catch (IOException e) {
//            LogUtil.e("makeLogFile error e:" + e.getMessage());
//            e.printStackTrace();
//        }
//        ToastUtil.showToast(isSuccess ? isClear ? "清理日志文件成功" : "生成日志文件成功" : "生成日志文件失败");
//    }
//
//    private void initFrame() {
//        int fps = SettingDataCenter.getInstance().getFps();
//        mSbFrame.setValue(fps);
//    }
//
//    private void initAudioRate() {
//        int audioRate = SettingDataCenter.getInstance().getAudioRate();
//        mSbAudioRate.setValue(audioRate);
//    }
//
////    private void initAudioCodeRate(){
////        mSbAudioRate.setValue(44);
////    }
//
//    private void initCodeRate() {
//        int width = SettingDataCenter.getInstance().getFrameWidth();
//        mLastCodeRate = SettingDataCenter.getInstance().getCodeRate();
//        switch (width) {
//            case 1980:
////                mRb1.setChecked(true);
//                initResolutionText(ResolutionEnum.P1080);
//                setResolution(ResolutionEnum.P1080);
//                setCodeRate(CodeRateEnum.P1080);
//                break;
//            case 1280:
////                mRb2.setChecked(true);
//                initResolutionText(ResolutionEnum.P720);
//                setResolution(ResolutionEnum.P720);
//                setCodeRate(CodeRateEnum.P720);
//                break;
//            case 854:
////                mRb3.setChecked(true);
//                initResolutionText(ResolutionEnum.P480);
//                setResolution(ResolutionEnum.P480);
//                setCodeRate(CodeRateEnum.P480);
//                break;
//            case 800:
////                mRb3.setChecked(true);
//                initResolutionText(ResolutionEnum.P450);
//                setResolution(ResolutionEnum.P450);
//                setCodeRate(CodeRateEnum.P450);
//                break;
//            case 640:
////                mRb4.setChecked(true);
//                initResolutionText(ResolutionEnum.P360);
//                setResolution(ResolutionEnum.P360);
//                setCodeRate(CodeRateEnum.P360);
//                break;
//            default:
//                break;
//        }
//        mSbCode.setValue(mLastCodeRate);
//    }
//
//    private void initResolutionText(ResolutionEnum resolutionEnum) {
//        mTvResolution.setText(resolutionEnum.getHeight() + "*" + resolutionEnum.getWidth());
//    }
//
//    private void initAudioType() {
//        int audioType = SettingDataCenter.getInstance().getAudioType();
//        if (CameraTypes.RECORD_CODEC_TYPE_AAC == audioType) {
//            mTvAudioType.setText("AAC");
//        } else {
//            mTvAudioType.setText("OPUS");
//        }
//    }
//
//    private void initVersion() {
//        mTvVersion.setText(AppUtil.getVersionName(this));
//    }
//
//    private void setCodeRate(CodeRateEnum codeRate) {
//        mSbCode.setMinAndMax(codeRate.getMin(), codeRate.getMax());
//        mSbCode.setValue(codeRate.getDefaultRate());
//        SettingDataCenter.getInstance().setCodeRate(codeRate.getDefaultRate());
//    }
//
//    private void setResolution(ResolutionEnum resolution) {
//        SettingDataCenter.getInstance().setFrameWidth(resolution.getWidth());
//        SettingDataCenter.getInstance().setFrameHeight(resolution.getHeight());
//    }
//
//    private void initSourceType() {
//        int camType = SettingDataCenter.getInstance().getSourceType();
//        if (camType == 1) {
//            mRbPhoneCamera.setChecked(true);
//        } else if (camType == 2) {
//            mRbUsbCamera.setChecked(true);
//        }
//        mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
//            @Override
//            public void onCheckedChanged(RadioGroup group, int checkedId) {
//                setSourceType();
//            }
//        });
//    }
//
//    private void setSourceType() {
//        int camType = 1;
//        if (mRbPhoneCamera.isChecked()) {
//            camType = 1;
//        }
//        if (mRbUsbCamera.isChecked()) {
//            camType = 2;
//        }
//        SettingDataCenter.getInstance().setSourceType(camType);
//    }
//
//
////    @Override
////    public void onUpgradeSuccess(UpgradeResultBean resultBean) {
////        if (null != resultBean
////                && !UpdateDialog.NO_UPGRADE.equals(resultBean.getUpgradeType())
////                && !TextUtils.isEmpty(resultBean.getIconurl())) {
////            updateDialog(resultBean.getFileDesc(),
////                    resultBean.getLastVersion(),
////                    resultBean.getIconurl(),
////                    resultBean.getUpgradeType());
////        } else {
////            ToastUtil.showToast("当前为最新版本");
////        }
////    }
//
//    /**
//     * 更新弹框提示
//     */
////    private void updateDialog(String desc, String lastVersion, String url, String upgradeType) {
////        UpdateDialog updateDialog = UpdateDialog.getInstance();
////        updateDialog.show(this,
////                desc,
////                url,
////                lastVersion,
////                upgradeType);//是否强制更新
////    }
//
//}
